<template>
	<view class="goods_detail">
	  <swiper indicator-dots>
		  <swiper-item v-for="item in swipers" :key="item.pics_id">
			  <image :src="item.pics_big"></image>
		  </swiper-item>
	  </swiper>
	  <view class="box1">
		  <view class="price">
			  <text>￥{{details.goods_price}}</text>
			  <text>￥{{details.goods_price+100}}</text>
		  </view>
		  <view class="goods_name">{{details.goods_name}}</view>
	  </view>
	  <view class="line"></view>
	  <view class="box2">
		  <view>货号：{{details.goods_id}}</view>
		  <view>库存：{{details.goods_number}}</view>
	  </view>
	  <view class="line"></view>
	  <view class="box3">
		  <view class="tit">介绍</view>
		  <view class="content">
			  <rich-text :nodes="details.goods_introduce"></rich-text>
		  </view>
	  </view>
	  <view class="goods_nav">
		  <uni-goods-nav :fill="true" :options="options" :buttonGroup="buttonGroup"  @click="onClick" @buttonClick="buttonClick" />
	  </view>
	</view>
</template>

<script>
	import uniGoodsNav from '@/components/uni-goods-nav/uni-goods-nav.vue'
	export default {
		data() {
			return {
				id:0,
				swipers:[],
				details:{},
				options: [{
				            icon: 'headphones',
				            text: '客服'
				        }, {
				            icon: 'shop',
				            text: '店铺',
				            // info: 2,
				            infoBackgroundColor:'#007aff',
				            infoColor:"red"
				        }, {
				            icon: 'cart',
				            text: '购物车',
				            info: 2
				        }],
				        buttonGroup: [{
				          text: '加入购物车',
				          backgroundColor: '#ff0000',
				          color: '#fff'
				        },
				        {
				          text: '立即购买',
				          backgroundColor: '#ffa200',
				          color: '#fff'
				        }
				        ]
				      
				    }
		},
		onLoad(options) {
			this.id=options.id
			console.log(this.id)
			this.getDetails()
		},
		components: {uniGoodsNav},
		methods: {
			async getDetails(){
				const res = await this.$myRequest({
					url:'/api/public/v1/goods/detail?goods_id='+this.id
				})
				this.details=res.message
				this.swipers=res.message.pics
				console.log(res)
			},
			onClick (e) {
			        uni.showToast({
			          title: `点击${e.content.text}`,
			          icon: 'none'
			        })
			      },
			      buttonClick (e) {
			        console.log(e)
			        this.options[2].info++
			      }
		}
	}
</script>

<style lang="scss">
.goods_detail{
	swiper{
		height: 600rpx;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.box1{
		padding: 10rpx;
		.price{
			font-size: 35rpx;
			line-height: 80rpx;
			color: $shop-color;
			text:nth-child(2){
				color:#ccc;
				font-size: 28rpx;
				text-decoration: line-through;
				margin-left: 20rpx;
			}
		}
		.goods_name{
			font-size: 35rpx;
			line-height: 60rpx;
		}
	}
	.line{
		height: 10rpx;
		width: 100%;
		background: #eee;
	}
	.box2{
		padding: 0 10rpx;
		font-size: 32rpx;
		line-height: 70rpx;
	}
	.box3{
		.tit{
			font-size: 30rpx;
			padding-left: 10px;
			border-bottom: 1px solid #eee;
			line-height: 70rpx;
		}
		.content{
			line-height: 50rpx;
			padding: 10px;
			font-size: 28rpx;
			color: #333333;
		}
		
	}
	.goods_nav{
		position: fixed;
        bottom: 0;
		width: 100%;
	}
}
</style>
